package com.littora.alarm.watch;

import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;

import java.io.File;

public class FileListener extends FileAlterationListenerAdaptor {
    private FileStatusCallback callback;

    public FileListener(FileStatusCallback callback) {
        this.callback = callback;
    }

    @Override
    public void onFileCreate(File file) {
        super.onFileCreate(file);
        callback.callback(file,FileStatusCallback.CREATE);
    }

    @Override
    public void onFileChange(File file) {
        super.onFileChange(file);
        callback.callback(file,FileStatusCallback.MODIFY);
    }

    @Override
    public void onFileDelete(File file) {
        super.onFileDelete(file);
        callback.callback(file,FileStatusCallback.DELETE);
    }
}
